/**
 * @author 李楠君
 * 用户登录
 */
package com.safe.ocs.services;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.safe.ocs.beans.Blogin;
import com.safe.ocs.utils.HibernateUtil;

public class UserLogin {
    
	/**
	 * 
	 * @param name  用户名
	 * @param pwd   密码
	 * @return      用户信息
	 */
	public Blogin certify(String name, String pwd) {
		Blogin userinfo = null;
		String hqlcert = "select new Blogin(ID,username,password) from Blogin where username=:name and password=:pwd";
		Session session = HibernateUtil.getSession();
		List info = session.createQuery(hqlcert).setParameter("name", name)
				.setParameter("pwd", pwd).list();
		if(info!=null&&info.size()>0)
			userinfo = (Blogin)info.get(0);
		return userinfo;
	}

}
